package Exception;

public class demo3 {
    public static void main(String[] args) {
        int []arr = {};
        int max = 0;
        try {
            max = getmax(arr);
        } catch (NullPointerException e) {
            System.out.println("空指针异常");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("索引值异常");
        }
        System.out.println("113");
    }

    public static int getmax(int[] arr) {
        if(arr == null){
            throw new NullPointerException();
        }
        if(arr.length == 0){
            throw new ArrayIndexOutOfBoundsException();
        }
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
        }
        return max;
    }
}
